<?php

class ZFKiller_Model extends Zend_Db_Table_Abstract {

    protected $_errors = array();
    protected $_messageTemplates = array();

    public function addError($errorNumber) {
	$this->_errors[] = $errorNumber;
    }

    public function clearErrors() {
	$this->_errors = array();
    }

    public function getErrors() {
	return $this->_errors;
    }

    public function getErrorsCount() {
	return count($this->_errors);
    }

    public function getErrorsMessages($data = array()) {
	if (count($this->_errors) == 0) {
	    return array();
	}

	$dataReplace = array();
	foreach ($data as $dataKey => $dataValue) {
	    $dataReplace['%' . $dataKey . '%'] = $dataValue;
	}

	$r = array();
	foreach ($this->_errors as $errorCode) {
	    $r[$errorCode] = strtr($this->_messageTemplates[$errorCode], $dataReplace);
	}

	return $r;
    }

    public function getTableName() {
	return $this->_name;
    }

}